<template>
  <div>
    <div class="text-btns" @click="less">-</div>
    <div class="text-num">{{ num }}</div>
    <div class="text-btns" @click="add">+</div>
  </div>
</template>


<script>
export default {
  name: "numberAdd",
  data() {
    return {
      num: 0,
    };
  },
  methods: {
    //商品数量增加
    add() {
      this.num++;
    },

    //商品数量减少
    less() {
      if (this.num > 0) {
        this.num--;
      }
    },
  },
};
</script>

<style scoped>
.text-btns {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: gold;
  text-align: center;
  line-height: 18px;
  font-size: 18px;
}
.text-num {
  display: inline-block;
  width: 20px;
  text-align: center;
  line-height: 20px;
  font-size: 14px;
}
</style>